var e = require;
var t = module;
var o = exports;
var n = o;
Object.defineProperty(n, "__esModule", {value: !0});
var i = e("AssetsMap"),
    a = e("BundleNames"),
    r = e("GlobalParam"),
    s = (function () {
        function e() {
            (this.isInit = !1), (this.gameModelInstance = null), (this.foodPoolList = null);
        }
        return (
            Object.defineProperty(e, "instance", {
                get: function () {
                    return e._instance || (e._instance = new e()), e._instance;
                },
                enumerable: !1,
                configurable: !0
            }),
            (e.prototype.init = function (e) {
                if (((this.gameModelInstance = e), this.isInit)) return e.__start();
                var t;
                (this.isInit = !0),
                    (this._blastPoolList = new cc.NodePool("blastPoolList")),
                    (this.bombPoolList = new cc.NodePool("bombPoolList")),
                    (this._bloodPoolList = new cc.NodePool("bloodPoolList")),
                    (this._speedPoolList = new cc.NodePool("speedPoolList"));
                for (var o = 0; o < 20; o++)
                    (t = game.UIManager.instance.createNodeByPreloading(
                        a.default.Game,
                        i.default.GameBundle.prefabs.assetsList.speed_prefab
                    )),
                        this.delSpeedNode(t);
                for (this.foodPoolList = new cc.NodePool("foodPoolList"), o = 0; o < 350; o++)
                    (t = game.UIManager.instance.createNodeByPreloading(
                        a.default.Game,
                        i.default.GameBundle.prefabs.assetsList.foodPrefab
                    )),
                        this.delFoodNode(t);
                for (
                    this.headNodePool = new cc.NodePool("headNodePool"), o = 0;
                    o < r.default.GameConfigData.SnakeMapNumber;
                    o++
                )
                    (t = game.UIManager.instance.createNodeByPreloading(
                        a.default.Game,
                        i.default.GameBundle.prefabs.assetsList.headPrefab
                    )),
                        this.delHeadNode(t);
                for (
                    this.tailNodePool = new cc.NodePool("tailNodePool"), o = 0;
                    o < r.default.GameConfigData.SnakeMapNumber;
                    o++
                )
                    (t = game.UIManager.instance.createNodeByPreloading(
                        a.default.Game,
                        i.default.GameBundle.prefabs.assetsList.tailPrefab
                    )),
                        this.delTailNode(t);
                for (this.bodyNodePool = new cc.NodePool("bodyNodePool"), o = 0; o < 250; o++)
                    (t = game.UIManager.instance.createNodeByPreloading(
                        a.default.Game,
                        i.default.GameBundle.prefabs.assetsList.bodyPrefab
                    )),
                        this.delBodyNode(t);
                e.__start();
            }),
            (e.prototype.getFoodNode = function () {
                var e = null;
                return (
                    ((e =
                        this.foodPoolList.size() > 0
                            ? this.foodPoolList.get()
                            : game.UIManager.instance.createNodeByPreloading(
                                  a.default.Game,
                                  i.default.GameBundle.prefabs.assetsList.foodPrefab
                              )).scale = 1),
                    e
                );
            }),
            (e.prototype.delFoodNode = function (e) {
                e.stopAllActions(), (e.scale = 1), (e.parent = null), this.foodPoolList.put(e);
            }),
            (e.prototype.clearFoodNode = function () {
                this.foodPoolList.clear();
            }),
            (e.prototype.getBombNode = function () {
                return this.bombPoolList.size() > 0
                    ? this.bombPoolList.get()
                    : game.UIManager.instance.createNodeByPreloading(
                          a.default.Game,
                          i.default.GameBundle.prefabs.assetsList.bomb_prefab
                      );
            }),
            (e.prototype.delBombNode = function (e) {
                this.bombPoolList.put(e);
            }),
            (e.prototype.clearBombNode = function () {
                this.bombPoolList.clear();
            }),
            (e.prototype.getBloodNode = function () {
                return this._bloodPoolList.size() > 0
                    ? this._bloodPoolList.get()
                    : game.UIManager.instance.createNodeByPreloading(
                          a.default.Game,
                          i.default.GameBundle.prefabs.assetsList.blood_prefab
                      );
            }),
            (e.prototype.delBloodNode = function (e) {
                this._bloodPoolList.put(e);
            }),
            (e.prototype.clearBloodNode = function () {
                this._bloodPoolList.clear();
            }),
            (e.prototype.getSpeedNode = function () {
                var e = null;
                return (
                    ((e =
                        this._speedPoolList.size() > 0
                            ? this._speedPoolList.get()
                            : game.UIManager.instance.createNodeByPreloading(
                                  a.default.Game,
                                  i.default.GameBundle.prefabs.assetsList.speed_prefab
                              )).zIndex = 10),
                    e
                );
            }),
            (e.prototype.delSpeedNode = function (e) {
                (e.active = !1), (e.parent = null), this._speedPoolList.put(e);
            }),
            (e.prototype.clearSpeedNode = function () {
                this._speedPoolList.clear();
            }),
            (e.prototype.getBlastNode = function () {
                var e = null;
                return (
                    this._blastPoolList.size() > 0
                        ? (e = this._blastPoolList.get())
                        : (e = new cc.Node("blast")).addComponent(cc.Sprite),
                    e
                );
            }),
            (e.prototype.delBlastNode = function (e) {
                this._blastPoolList.put(e);
            }),
            (e.prototype.clearBlastNode = function () {
                this._blastPoolList.clear();
            }),
            (e.prototype.getHeadNode = function () {
                return this.headNodePool.size() > 0
                    ? this.headNodePool.get()
                    : game.UIManager.instance.createNodeByPreloading(
                          a.default.Game,
                          i.default.GameBundle.prefabs.assetsList.headPrefab
                      );
            }),
            (e.prototype.delHeadNode = function (e) {
                (e.parent = null), this.headNodePool.put(e);
            }),
            (e.prototype.clearHeadNode = function () {
                this.headNodePool.clear();
            }),
            (e.prototype.getTailNode = function () {
                return this.tailNodePool.size() > 0
                    ? this.tailNodePool.get()
                    : game.UIManager.instance.createNodeByPreloading(
                          a.default.Game,
                          i.default.GameBundle.prefabs.assetsList.tailPrefab
                      );
            }),
            (e.prototype.delTailNode = function (e) {
                (e.parent = null), this.tailNodePool.put(e);
            }),
            (e.prototype.clearTailNode = function () {
                this.tailNodePool.clear();
            }),
            (e.prototype.getBodyNode = function () {
                return this.bodyNodePool.size() > 0
                    ? this.bodyNodePool.get()
                    : game.UIManager.instance.createNodeByPreloading(
                          a.default.Game,
                          i.default.GameBundle.prefabs.assetsList.bodyPrefab
                      );
            }),
            (e.prototype.delBodyNode = function (e) {
                (e.parent = null), this.bodyNodePool.put(e);
            }),
            (e.prototype.clearBodyNode = function () {
                this.bodyNodePool.clear();
            }),
            (e._instance = null),
            e
        );
    })();
n.default = s;
